package com.chris.libs.http.x.v1.normal;

import com.chris.libs.devtools.x.v1.utils.StorageUtil;
import com.chris.libs.http.x.v1.constants.SPKeys;

/**
 * @author Chris chan
 * Create on： 2025/2/17 13:51
 * Use for:
 * Explain:
 */
public class TokenUtil {
    /**
     * 读取访问令牌
     *
     * @return
     */
    public static String getAuthorization() {
        String authorization = StorageUtil.read(SPKeys.ACCESS_TOKEN, null);
        if (null == authorization || authorization.isEmpty()) {
            return null;
        }
        return "Bearer " + authorization;
    }

    /**
     * 存入访问令牌
     *
     * @param authorization
     */
    public static void setAuthorization(String authorization) {
        StorageUtil.save(SPKeys.ACCESS_TOKEN, authorization);
    }

    /**
     * 删除访问令牌
     */
    public static void remove() {
        StorageUtil.remove(SPKeys.ACCESS_TOKEN);
    }
}
